package com.qcby.config;



import com.qcby.aspect.PrintArgsAspect;
import com.qcby.aspect.PrintArgsProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 打印api args配置
 *
 * @author cong.zhen
 * @date 2023/12/12
 */

@Configuration
@EnableConfigurationProperties({PrintArgsProperties.class})
public class PrintApiArgsConfiguration {

    private final PrintArgsProperties printArgsProperties;

    public PrintApiArgsConfiguration(PrintArgsProperties printArgsProperties) {
        this.printArgsProperties = printArgsProperties;
    }

    @Bean
    @ConditionalOnProperty(
            prefix = "com.qcby.args.print",
            name = {"enabled"},
            havingValue = "true",
            matchIfMissing = true
    )
    public PrintArgsAspect printArgsAspect() {
        return new PrintArgsAspect(this.printArgsProperties);
    }
}
